import loadjs from "loadjs";
import { WeaTools } from 'ecCom';
const { WindowFunc } = WeaTools;

// 获取 window
const getCurrentWindow = () => {
    // if (this.state.hasSetWindow) {
    //   return window["setUploadWindow" + this.state.containerId];
    // }
    return WindowFunc.getParent() !== window &&
        $(this.refs.wrap).closest(".ant-modal").length > 0
        ? WindowFunc.getTop()
        : window;
    // return WindowFunc.getParent() !== window
    //   ? WindowFunc.getTop()
    //   : window;
};
const getCurrentJQuery = () => {
    const currentWindow = getCurrentWindow();
    return currentWindow.$ || currentWindow.jQuery;
};
export const viewer = (imgPool, indexNum) => {
    // let source = e.target;
    console.log(imgPool)
    const currentWindow = getCurrentWindow();
    const windowEcCom = currentWindow.ecCom;
    let load = windowEcCom ? windowEcCom.WeaUpload.loadjs : loadjs;
    load.isDefined("imcarouselJS")
        ? load.ready("imcarouselJS", function () {
            // 图片轮播
            IMCarousel.showImgScanner4Pool(
                true,
                imgPool,
                indexNum,
                null,
                WindowFunc.getTop()
            );
        })
        : load(
            [
                "/social/js/drageasy/drageasy.js",
                "/social/js/bootstrap/js/bootstrap.js",
                "/social/im/js/IMUtil_wev8.js",
                "/social/js/imcarousel/imcarousel.js"
            ],
            "imcarouselJS",
            function () {
                // 图片轮播
                IMCarousel.showImgScanner4Pool(
                    true,
                    imgPool,
                    indexNum,
                    null,
                    WindowFunc.getTop()
                );
            }
        );
};



// WEBPACK FOOTER //
// ./ecology9/wea-tools/viewer.js